Crate smallvec

source ·
Expand description

Small vectors in various sizes. These store a certain number of elements inline, and fall back to the heap for larger allocations. This can be a useful optimization for improving cache locality and reducing allocator traffic for workloads that fit within the inline buffer.

§no_std support

By default, smallvec does not depend on std. However, the optional write feature implements the std::io::Write trait for vectors of u8. When this feature is enabled, smallvec depends on std.

§Optional features

§std

When this feature is enabled, traits available from std are implemented:

This feature is not compatible with #![no_std] programs.

§serde

When this optional dependency is enabled, SmallVec implements the serde::Serialize and serde::Deserialize traits.

§extract_if

This feature is unstable. It may change to match the unstable extract_if method in libstd.

Enables the extract_if method, which produces an iterator that calls a user-provided closure to determine which elements of the vector to remove and yield from the iterator.

§specialization

This feature is unstable and requires a nightly build of the Rust toolchain.

When this feature is enabled, SmallVec::from(slice) has improved performance for slices of Copy types. (Without this feature, you can use SmallVec::from_slice to get optimal performance for Copy types.)

Tracking issue: rust-lang/rust#31844

§may_dangle

This feature is unstable and requires a nightly build of the Rust toolchain.

This feature makes the Rust compiler less strict about use of vectors that contain borrowed references. For details, see the Rustonomicon.

Tracking issue: rust-lang/rust#34761

Macros§

Structs§

  • An iterator that removes the items from a SmallVec and yields them by value.
  • An iterator which uses a closure to determine if an element should be removed.
  • An iterator that consumes a SmallVec and yields its items by value.

Enums§

Unions§

  • Either a stack array with length <= N or a heap array whose pointer and capacity are stored here.